---附加x属性的n%的伤害 [基础值,目标,x属性,万分比]
---@class BuffEffect4 : BaseBuffEffect
BuffEffect4 = ClientFight.CreateClass("BuffEffect4", ClientFight.BaseBuffEffect)
local t = BuffEffect4

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = { ... }
    if (#parameters < 3) then
        return ClientFight.BaseBuffEffect.action(self,fight, buff, parameters);
    end
    local target = parameters[1];
    local result = parameters[3];
    if (not AttackUtils.isDamage(result:getState())) then
        return ClientFight.BaseBuffEffect.action(self,fight, buff, parameters);
    end
    local fighter = nil;
    if (buff.buffBean.f_BuffEffectValue[2] == 0) then
        fighter = buff.source
    else
        fighter = buff.target;
    end
    local source = buff.source
    if (target.teamIndex == source.teamIndex) then --//附加伤害 不对友方生效
        return ClientFight.BaseBuffEffect.action(self,fight, buff, parameters);
    end
    local attr = FighterAttributeManager.getFightAttr(fighter, buff.buffBean.f_BuffEffectValue[3])
    local add = attr * buff.buffBean.f_BuffEffectValue[4] / Global.TEN_THOUSANDTH
    + buff.buffBean.f_BuffEffectValue[1];
    add=add*buff.overlay
    SkillRoleMgr.savePathFile( "[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
    .. buff.modelId .. " 触发附加自身属性额外伤害BUFF效果");

    local damage = result:getDamage() + add;
    --local logAdd = add;
    --local logFighter = fighter;
    SkillRoleMgr.savePathFile(
    "[" .. fight.frame .. "][DAMAGE]" .. buff.source.fighterId .. "对"
    .. buff.target.fighterId .. "计算BUFF(" .. buff.modelId .. ")附加[" ..logFighter.fighterId.."]的" .. FighterAttributeEnum.valueOf(buff.buffBean.f_BuffEffectValue[2]).chinese+",附加伤害"
    .. NumberFormatUtil.formatDamage(logAdd)+" 总伤害:" ..damage+" , 配置表参数:" .. Arrays.toString(buff.buffBean.f_BuffEffectValue));
    result:setDamage(damage);

    return ClientFight.BaseBuffEffect.action(self,fight, buff, parameters);
end

t.New()